package com.shengsiyuan.netty.firstexample;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * Created by deng_wb on 2019/7/31
 * 服务端初始化器
 */
public class TestServerInitializer extends ChannelInitializer<SocketChannel> {

    /** 连接一旦建立则回调此方法 **/
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {

        ChannelPipeline pipeline = ch.pipeline();
        pipeline.addLast("httpServerCodec",new HttpServerCodec()); // 简化请求/响应编解码动作
        pipeline.addLast("testHttpServerHandler",new TestHttpServerHandler());

    }
}
